package cn.jussi.dao;

import java.util.List;

import cn.jussi.model.UploadFile;

public class UploadFileDaoImpl extends BaseDao<UploadFile> implements UploadFileDao {

	@Override
	public void addFileInfo(UploadFile uploadFile) {
		String sql = "insert into uploadfiles(old_file_name, file_type, file_size, save_path, save_time, [desc], save_name) values(?,?,?,?,?,?,?)";
		super.update(sql, uploadFile.getOldFileName(), uploadFile.getFileType(), uploadFile.getFileSize(), uploadFile.getSavePath(), uploadFile.getSaveTime(), uploadFile.getDesc(), uploadFile.getSaveName());
		
	}

	@Override
	public List<UploadFile> getUploadFilesInfo() {
		String sql = "select id, old_file_name oldFileName, file_type fileType, file_size fileSize, save_path savePath, save_time saveTime, [desc], save_name saveName from uploadfiles";
		return super.getList(sql);
	}

	@Override
	public void deleteUploadFileInfo(int id) {
		String sql = "delete from uploadfiles where id=?";
		super.update(sql, id);
	}

	@Override
	public UploadFile get(int id) {
		String sql = "select id, old_file_name oldFileName, file_type fileType, file_size fileSize, save_path savePath, save_time saveTime, [desc], save_name saveName from uploadfiles where id=?";
		return super.get(sql, id);
	}

}
